﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpPcClient.WpfClient.Service.Common
{
    public class ResultModel
    {
        public dynamic Result {
            get;
            set;
        }
        //
        // 摘要:
        //     This property can be used to redirect user to a specified URL.
        public string TargetUrl
        {
            get;
            set;
        }

        //
        // 摘要:
        //     Indicates success status of the result. Set Abp.Web.Models.AjaxResponseBase.Error
        //     if this value is false.
        public bool Success
        {
            get;
            set;
        }

        //
        // 摘要:
        //     Error details (Must and only set if Abp.Web.Models.AjaxResponseBase.Success is
        //     false).
        public ErrorInfo Error
        {
            get;
            set;
        }

        //
        // 摘要:
        //     This property can be used to indicate that the current user has no privilege
        //     to perform this request.
        public bool UnAuthorizedRequest
        {
            get;
            set;
        }

        //
        // 摘要:
        //     A special signature for AJAX responses. It's used in the client to detect if
        //     this is a response wrapped by ABP.
        public bool __abp
        {
            get;
        } = true;

    }

    public class ErrorInfo
    {
        //
        // 摘要:
        //     Error code.
        public int Code
        {
            get;
            set;
        }

        //
        // 摘要:
        //     Error message.
        public string Message
        {
            get;
            set;
        }

        //
        // 摘要:
        //     Error details.
        public string Details
        {
            get;
            set;
        }

        //
        // 摘要:
        //     Validation errors if exists.
        public ValidationErrorInfo[] ValidationErrors
        {
            get;
            set;
        }

    }

    public class ValidationErrorInfo
    {
        public string Message
        {
            get;
            set;
        }

        //
        // 摘要:
        //     Relate invalid members (fields/properties).
        public string[] Members
        {
            get;
            set;
        }
    }
}
